const modules = import.meta.glob('../view/**/*.vue')

function loadView(component) {
  // component 例如: "assets/tabs/HardwareInfo.vue"
  const path = `../view/${component}`
  return modules[path] || (() => import('../view/404.vue'))
}
function generateRoutes(menuTree) {
  return menuTree.map(item => {
    const route = {
      path: item.path,
      name: item.name,
      meta: { menuId: item.id, title: item.name },
      component: item.component ? loadView(item.component) : loadView('layout/EmptyLayout.vue')
    }

    if (item.children && item.children.length > 0) {
      route.children = generateRoutes(item.children)
    }

    return route
  })
}
export default generateRoutes


